package packge.obj;

class ObTest2 {
	public static void main(String str[]) {
		String s1 = "JLC";
		String s2 = new String("JLC");
		System.out.println(s1 + "\t" + s2);
		System.out.println(s1 == s2);
		System.out.println(s1.equals(s2));
		User us1 = new User(99, "srinivas");
		User us2 = new User(99, "srinivas");
		User us3 = us1;
		System.out.println("--  == with User  --");
		System.out.println(us1 == us2);
		System.out.println(us1 == us3);
		System.out.println(us2 == us3);
		System.out.println("--  .equals(us) with User()  --");
		System.out.println(us1.equals(us2));
		System.out.println(us1.equals(us3));
		System.out.println(us2.equals(us3));
		Employee1 emp1 = new Employee1(99, "Srinivas");
		Employee1 emp2 = new Employee1(99, "Srinivas");
		Employee1 emp3 = new Employee1(23, "Srinivas");
		Employee1 emp4 = emp1;
		System.out.println("--  == with Employee  --");
		System.out.println(emp1 == emp2);
		System.out.println(emp1 == emp3);
		System.out.println(emp2 == emp3);
		System.out.println(emp1 == emp4);
		System.out.println("--  .equals(emp) with Employee  --");
		System.out.println(emp1.equals(emp2));
		System.out.println(emp1.equals(emp3));
		System.out.println(emp2.equals(emp3));
		System.out.println(emp1.equals(emp4));
	}
}

class User {
	int uid;
	String uname;

	User(int uid, String uname) {
		this.uid = uid;
		this.uname = uname;
	}
}

class Employee1 {
	int eid;
	String ename;

	Employee1(int eid, String ename) {
		this.eid = eid;
		this.ename = ename;
	}

	public boolean equals(Object obj) {
		Employee1 emp = (Employee1) obj;
		return this.eid == emp.eid && this.ename.equals(emp.ename);
	}
}